<template>
  <el-dialog title="添加风控" :visible.sync="dialogVisible" width="600px">
    <el-form ref="ruleForm" class="ruleForm" :model="searchForm" :rules="rules" label-width="100px">
      <el-form-item label="姓名" prop="realname">
        <el-input v-model="searchForm.cert_name" clearable maxlength="10" placeholder="请输入姓名" />
      </el-form-item>
      <el-form-item label="联系电话" prop="mobile">
        <el-input v-model="searchForm.mobile" clearable maxlength="11" placeholder="请输入联系电话" />
      </el-form-item>
      <el-form-item label="证件号码" prop="cert_no">
        <el-input v-model="searchForm.cert_no" clearable placeholder="请输入姓名" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="small" @click="dialogVisible = false">取 消</el-button>
      <el-button size="small" type="primary" @click="submit">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { setAntRiskList } from '@/api/data'
export default {
  data() {
    return {
      dialogVisible: false,
      searchForm:{
        cert_name:'',
        mobile:'',
        cert_no:''
      },
    }
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.$nextTick(() => {
          this.getList()
        })
      }else{
        this.$refs['ruleForm'].resetFields()
      }
    }
  },
  methods: {
    getList() {
      
    },
    submit(){
      this.$refs['ruleForm'].validate((valid) => {
        if (valid) {
          setAntRiskList({...this.searchForm}).then(res => {
            this.dialogVisible = false
            this.$emit('getList', true)
          })
        } else {
          this.$message({
            message: '请检查表单错误',
            type: 'error'
          })
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
